﻿/* 
	Creates a new Subtool that contains spherical eyeballs with the ToyPlastic Material applied
*/

/////////////////////////////////////////
// User Changeable Options ///////////////
/////////////////////////////////////////

[VarDef,gRRR,0] // Sets the Red Value (Default 0)
[VarDef,gGGG,0] // Sets the Green Value (Default 0)
[VarDef,gBBB,0] // Sets the Blue Value (Default 0)

[VarDef,gXYZSize,0.5] // Sets the XYZ Size for the sphere. (Default .5)
[VarDef,gXOffset,-0.8] // Sets the X Offset (Default -0.8)
[VarDef,gYOffset,0] // Sets the X Offset (Default 0)
[VarDef,gZOffset,0] // Sets the X Offset (Default 0)

[VarDef,gXMod,1] // Sets Mirror and Weld to the X axis (Default 1. Set to 1 to Enable. Also needs a gXOffset value to work.)
[VarDef,gYMod,0] // Sets Mirror and Weld to the Y axis (Default 0. Set to 2 to Enable. Also needs a gYOffset value to work.)
[VarDef,gZMod,0] // Sets Mirror and Weld to the Z axis (Default 0. Set to 4 to Enable. Also needs a gZOffset value to work.)

[VarDef,gReturnToSubtool,0] // Returns to the original Subtool that was selected (Default 0)

/////////////////////////////////////////
/////////////////////////////////////////

[RoutineDef,CreateEyeballs,

	// Store Current Material
	[VarSet,gSelMaterial,[IGetTitle, Material:Current Material]]
	
	// Store Current Selected Color
	[VarSet,RRR,[IGet,Color:R]]
	[VarSet,GGG,[IGet,Color:G]]
	[VarSet,BBB,[IGet,Color:B]]

	// Store MRGB Settings
	[VarSet,SetMRGB,[IGet,Draw:Mrgb]]
	[VarSet,SetRGB,[IGet,Draw:Rgb]]
	[VarSet,SetM,[IGet,Draw:M]]

	// Store Current Selected Subtool
	[VarSet,activeST,[SubToolGetActiveIndex]]

	// Insert a Sphere 3D Object
	[IPress,Tool:SubTool:Insert]
	[IPress,PopUp:Sphere3D]

	// Change Object size and position
	[ISet,Tool:Geometry:X Position,gXOffset]
	[ISet,Tool:Geometry:Y Position,gYOffset]
	[ISet,Tool:Geometry:Z Position,gZOffset]
	[ISet,Tool:Geometry:XYZ Size,gXYZSize]

	[ISet,Draw:Mrgb,1]
	[IPress,Material:ToyPlastic]

	// Set Color and Fill
	[IColorSet,gRRR,gGGG,gBBB]
	[IPress,Color:FillObject]

	// Process what Mirror and Weld Values to use
	[VarSet,MandWModSet,gXMod + gYMod + gZMod]
	[IKeyPress,2,[IModSet,Tool:Geometry:Mirror And Weld,MandWModSet]]

	// Mirror and Weld to create 2 eyeballs. 
	[IPress,Tool:Geometry:Mirror And Weld]

	// Activate Symmetry on the tool and Center Gizmo to a single eyeball
	[If,gXMod,
		[ISet,Transform:>X<,1]
	,
		[ISet,Transform:>X<,0]
	]
	[If,gYMod,
		[ISet,Transform:>Y<,1]
	,
		[ISet,Transform:>Y<,0]
	]
	[If,gZMod,
		[ISet,Transform:>Z<,1]
	,
		[ISet,Transform:>Z<,0]
	]
	[IPress,Transform:Activate Symmetry]
	[IPress,Tool:Masking:Clear]
	[IPress,Tool:Masking:Go To Unmasked Center]

	// Return to Initial Subtool?
	[If,gReturnToSubtool,
		[SubToolSelect,activeST]
	,]

	// Return to Initial Material and Color
	[IPress,[StrMerge,"Material:",gSelMaterial]]
	[IColorSet,RRR,GGG,BBB]

	// Return MRGB settings
	[ISet,Draw:Mrgb,SetMRGB]
	[ISet,Draw:Rgb,SetRGB]
	[ISet,Draw:M,SetM]
]

[IButton,???,"Creates a new Subtool that contains spherical eyeballs with the ToyPlastic Material applied (Edit Macro for Options.)",
	[IShowActions,0]
	[IConfig,4.8]
	//[IFreeze,
		[RoutineCall,CreateEyeballs]
	//]
,,1,,,]